import urllib.request as req
import urllib.parse
import urllib.error


try:
    url = 'http://www.kfc123.com'
    data = {
        "cname1": "南昌1w2312",
        "pid": "",
        "pageIndex": "1",
        "pageSize": "10"
    }
    data = urllib.parse.urlencode(data).encode("utf-8")
    header = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.26"
    }
    request = req.Request(url=url, data=data, headers=header)
    res = req.urlopen(request)
    con = res.read().decode("utf-8")
    print(con)
except urllib.error.HTTPError:
    print("系统升级")
except urllib.error.URLError:
    print("系统不行了")


